<template>
	<div class="Task">
		<van-tabs v-model="active">
			<van-tab :title="item.name" v-for="item in list" :key="item.id">
				<div class="list-item" v-for="str in item.child" :key="str.id">
					<div class="title">{{str.title}}</div>
					<div class="info">
						<span class="time">{{str.createtime_text}}</span>
						<span class="time">{{str.user.nickname}}发布</span>
					</div>
					
				</div>
			</van-tab>
		</van-tabs>
	</div>
</template>

<script>
	export default {
		name: "Task",
		components: {

		},
		data() {
			return {
				active: 0,
				siteType: 1,
				list: []
			}
		},
		mounted() {
			this.siteType = this.$localStorage.get("siteType")
		},
		methods: {

			getData(item) {
				this.title = item.name
				this.$api.home.nav({
					type: this.siteType,
					pid: item.id
				}).then(res => {
					// 执行某些操作
					if (res.code == 1) {
						this.list = res.data
						this.getArticle()
					}

				})
			},
			getArticle() {
				let that = this
				this.list.forEach(item => {
					that.$api.home.task({
						site_id: this.$localStorage.get("site_id")
					}).then(res => {
						// 执行某些操作
						if (res.code == 1) {
							that.$set(item, "child", res.data.data)
						}

					})
				})

			},
			todetail(item) {
				this.$router.push({
					name: 'articledetail',
					query: {
						id: item.id
					}
				})
			}
		}


	}
</script>

<style lang="less">
	.Task {
		margin-top: 0.25rem;

		.list-item {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.title {
				font-size:0.81rem;
				font-family:PingFang SC;
				font-weight:500;
				color:rgba(50,50,50,1);
				display: inline-block;
				width:100%;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.time {
				font-size:0.69rem;
				font-family:PingFang SC;
				font-weight:500;
				color:rgba(137,137,137,1);
				margin-right: 2.09rem;
				margin-top: 1.03rem;
			}
		}
		.van-tabs__line{
			display: none!important;
		}
		.van-tab--active span{
			font-weight:bold;
			color:rgba(254,119,0,1);
		}
		.van-tab{
			font-size:0.88rem;
			font-family:PingFang SC;
			font-weight:500;
			color:rgba(89,89,89,1);
		}
	}
	
</style>
